﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="AddressesManagement.aspx.cs"
    Inherits="WebApplication.Restricted.Management.Company.AddressesManagement" %>

<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<%@ Register Assembly="System.Web.Entity, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
    Namespace="System.Web.UI.WebControls" TagPrefix="asp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
    </telerik:RadScriptManager>
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" DefaultLoadingPanelID="RadAjaxLoadingPanel1">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="AddressesGrid">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="AddressesGrid" LoadingPanelID="RadAjaxLoadingPanel1" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
    <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" Skin="Default">
    </telerik:RadAjaxLoadingPanel>
    <telerik:RadGrid ID="AddressesGrid" runat="server" AllowFilteringByColumn="True"
        AutoGenerateDeleteColumn="True" AutoGenerateEditColumn="True" AllowSorting="True"
        AllowPaging="True" GridLines="None" Skin="WebBlue" DataSourceID="AddressesEntityDataSource"
        OnDeleteCommand="AddressesGrid_DeleteCommand" OnInsertCommand="AddressesGrid_InsertCommand"
        OnUpdateCommand="AddressesGrid_UpdateCommand">
        <MasterTableView AutoGenerateColumns="False" CommandItemDisplay="Top" EditMode="EditForms"
            DataSourceID="AddressesEntityDataSource" DataKeyNames="Id">
            <RowIndicatorColumn>
                <HeaderStyle Width="20px"></HeaderStyle>
            </RowIndicatorColumn>
            <ExpandCollapseColumn>
                <HeaderStyle Width="20px"></HeaderStyle>
            </ExpandCollapseColumn>
            <Columns>
                <telerik:GridBoundColumn DataField="Id" DataType="System.Int32" HeaderText="Id" ReadOnly="True"
                    SortExpression="Id" UniqueName="Id">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="District" HeaderText="Dystrykt" SortExpression="District"
                    UniqueName="District">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="Street" HeaderText="Ulica" SortExpression="Street"
                    UniqueName="Street">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="BuildingNumber" HeaderText="Nr budynku" SortExpression="BuildingNumber"
                    UniqueName="BuildingNumber">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="LocalNumber" HeaderText="Nr lokalu" SortExpression="LocalNumber"
                    UniqueName="LocalNumber">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="CityId" DataType="System.Int32" HeaderText="City.Id"
                    SortExpression="City.Id" UniqueName="CityId" Visible="false">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="CityName" HeaderText="Miasto" SortExpression="CityName"
                    UniqueName="CityName">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="ProvinceName" HeaderText="Województwo" SortExpression="ProvinceName"
                    UniqueName="ProvinceName">
                </telerik:GridBoundColumn>
            </Columns>
            <EditFormSettings EditFormType="WebUserControl" UserControlName="~/Controls/Management/Company/AddressEditControl.ascx">
                <EditColumn UniqueName="EditCommandColumn1">
                </EditColumn>
                <%--<popupsettings modal="True" />--%>
            </EditFormSettings>
        </MasterTableView>
    </telerik:RadGrid>
    <asp:EntityDataSource ID="AddressesEntityDataSource" runat="server" ConnectionString="name=MerchModelEntities"
        DefaultContainerName="MerchModelEntities" CommandText="select address.Id as Id, address.District as District, address.Street as Street, address.BuildingNumber as BuildingNumber, address.LocalNumber as LocalNumber, city.Id as CityId, city.Name as CityName, province.Name as ProvinceName from MerchModelEntities.Address as address join MerchModelEntities.City as city on address.City = city join MerchModelEntities.Province as province on city.Province = province"
        Select="it.[Id], it.[District], it.[Street], it.[BuildingNumber], it.[LocalNumber], it.[BuildingNumber], it.[CityId], it.[CityName], it.[ProvinceName]"
        OrderBy="it.[Id]">
    </asp:EntityDataSource>
    </form>
</body>
</html>
